﻿/* 
 * File:   str_ext.h
 * Author: aple
 */

#ifndef __STACK_EXT_H_H_
#define	__STACK_EXT_H_H_

#include "stdint.h"

#ifdef	__cplusplus
extern "C" {
#endif

	/*fifo manager*/
	typedef struct
	{
		uint16_t site_put;//指向将要存储的空位
		uint16_t site_get;//指向准备获取数据位置
		uint16_t size;
		void * dat;
		void(*os_lock)(void);
		void(*os_unlock)(void);
	} fifo_quene_type;

	int8_t fifo32_put(fifo_quene_type *obj, uint32_t dat_in);	//return : 0-err, 1-ok
	int8_t fifo32_get(fifo_quene_type *obj, uint32_t *dat_out);	//return : 0-err, 1-ok
	int8_t fifo16_put(fifo_quene_type *obj, uint16_t dat_in);	//return : 0-err, 1-ok
	int8_t fifo16_get(fifo_quene_type *obj, uint16_t *dat_out);	//return : 0-err, 1-ok
	uint16_t fifo_amount(fifo_quene_type *obj);

	/*stack manager, 后进先出*/
	typedef struct
	{
		uint16_t site;//指向将要存储的空位
		uint16_t size;
		void * dat;
		void(*os_lock)(void);
		void(*os_unlock)(void);
	} stack_quene_type;

	int8_t stack32_put(stack_quene_type *obj, uint32_t dat_in);		//return : 0-err, 1-ok
	int8_t stack32_get(stack_quene_type *obj, uint32_t *dat_out);	//return : 0-err, 1-ok
	int8_t stack16_put(stack_quene_type *obj, uint16_t dat_in);		//return : 0-err, 1-ok
	int8_t stack16_get(stack_quene_type *obj, uint16_t *dat_out);	//return : 0-err, 1-ok
	uint16_t stack_amount(stack_quene_type *obj);


#ifdef	__cplusplus
}
#endif

#endif	/* __STACK_EXT_H_H_ */

